package com.oa.item.dao;

import org.apache.ibatis.jdbc.SQL;

import com.oa.item.entity.Plan;

public class PlanSqlProvider {

    public String insertSelective(Plan record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("plan");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getStarTime() != null) {
            sql.VALUES("star_time", "#{starTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEndTime() != null) {
            sql.VALUES("end_time", "#{endTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getPlanName() != null) {
            sql.VALUES("plan_name", "#{planName,jdbcType=VARCHAR}");
        }
        
        if (record.getCreater() != null) {
            sql.VALUES("creater", "#{creater,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatTime() != null) {
            sql.VALUES("creat_time", "#{creatTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdater() != null) {
            sql.VALUES("updater", "#{updater,jdbcType=VARCHAR}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getSpar() != null) {
            sql.VALUES("spar", "#{spar,jdbcType=VARCHAR}");
        }
        
        if (record.getPlanContent() != null) {
            sql.VALUES("plan_content", "#{planContent,jdbcType=LONGVARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Plan record) {
        SQL sql = new SQL();
        sql.UPDATE("plan");
        
        if (record.getStarTime() != null) {
            sql.SET("star_time = #{starTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEndTime() != null) {
            sql.SET("end_time = #{endTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getPlanName() != null) {
            sql.SET("plan_name = #{planName,jdbcType=VARCHAR}");
        }
        
        if (record.getCreater() != null) {
            sql.SET("creater = #{creater,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatTime() != null) {
            sql.SET("creat_time = #{creatTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdater() != null) {
            sql.SET("updater = #{updater,jdbcType=VARCHAR}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getSpar() != null) {
            sql.SET("spar = #{spar,jdbcType=VARCHAR}");
        }
        
        if (record.getPlanContent() != null) {
            sql.SET("plan_content = #{planContent,jdbcType=LONGVARCHAR}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}